#if defined GCMD_INCLUDED
#endinput
#endif
#define GCMD_INCLUDED

#include <a_samp>
#include <myfuncs>

#if defined FILTERSCRIPT
public OnRconCommand(cmd[])
{
	new tmp[32], tmpcmd[128], playerid;
	new idx, res;
	tmp = strtok(cmd, idx);
	//printf("%s/%s", cmd, tmp);
	if(!strcmd(tmp, "gcmd")) return false;
	tmp = strtok(cmd, idx);
	if(isnull(tmp)) return print("Usage: gcmd [playerid] [/command]"),true;
	playerid = strid(tmp);
	if(!IsPlayerConnected(playerid)) return print("Incorrect ID!"),true;
	cmdend(tmpcmd, cmd, strlen(tmp) + 6);
	if(isnull(tmpcmd)) return print("Usage: gcmd [playerid] [/command]"),true;
	res = OnPlayerCommandText(playerid, tmpcmd);
	if(res) printf("Success: %s", tmpcmd);
	//else print("Unknown command.");
	return res;
}

#else

public OnRconCommand(cmd[])
{
	new tmp[32], tmpcmd[128], playerid;
	new idx, res;
	tmp = strtok(cmd, idx);
	//printf("%s/%s", cmd, tmp);
	if(strcmd(tmp, "gcmd"))
	{
		tmp = strtok(cmd, idx);
		if(isnull(tmp)) return print("Usage: gcmd [playerid] [/cmd]"),true;
		playerid = strid(tmp);
		cmdend(tmpcmd, cmd, strlen(tmp) + 6);
		if(isnull(tmpcmd)) return print("Usage: gcmd [playerid] [/cmd]"),true;
		res = OnPlayerCommandText(playerid, tmpcmd);
		if(res) printf("Success: %s", tmpcmd);
		else print("Unknown command.");
		return true;
	} else
	if(strcmd(tmp,"gchat"))
	{
		//new tmp[32], tmptxt[128];
		//new playerid;
		tmp = strtok(cmd, idx);
		if(isnull(tmp)) return print("Usage: gchat [playerid] [msg]"),true;
		playerid = strid(tmp);
		if(!IsPlayerConnected(playerid)) return print("Incorrect ID!"),true;
		cmdend(tmpcmd, cmd, idx+1);
		if(isnull(tmpcmd)) return print("Usage: gchat [playerid] [msg]"),true;
		SendPlayerMessageToAll(playerid, tmpcmd);
		return true;
	}
	return false;
}
#endif
